package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.ColdStorageEntity;
import com.jinmdz.fmis.mapper.mapper.provider.ColdStorageProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 冷藏业务表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface ColdStorageMapper {

    /**
     * 增加ColdStorage
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = ColdStorageProvider.class, method = "insertColdStorage")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertColdStorage(@Param("entity") ColdStorageEntity entity);

    /**
     * 删除ColdStorage
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update cold_storage set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForColdStorage(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改ColdStorage
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = ColdStorageProvider.class, method = "updateColdStorage")
    void updateColdStorage(@Param("entity") ColdStorageEntity entity);

    /**
     * 查询ColdStorage实体
     *
     * @param id 主键
     * @return ColdStorageEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,business_code,equipment_type_code,equipment_id,appointment_in_time,appointment_out_time,reality_in_time,reality_out_time,process_state_code,rule_number,rule_unit,rule_code,rule_remark,remark,random_code,charge_id,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from cold_storage where id = #{id} and deleted = 0 limit 1 ")
    ColdStorageEntity getColdStorageById(@Param("id") Integer id);

    /**
     * 查询ColdStorage列表
     *
     * @param entity 数据实体
     * @return ColdStorageEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = ColdStorageProvider.class, method = "listColdStorage")
    ArrayList<ColdStorageEntity> listColdStorage(@Param("entity") ColdStorageEntity entity);
}